package com.ruoyi.web.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.web.domain.ZjgkjEntry;
import com.ruoyi.web.request.GetAllReq;
import com.ruoyi.web.service.ZjgkjEntryService;
import com.ruoyi.web.mapper.ZjgkjEntryMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
* @author chen
* @description 针对表【zjgkj_entry(紫金港科技报名列表)】的数据库操作Service实现
* @createDate 2024-07-25 17:02:26
*/
@Service
public class ZjgkjEntryServiceImpl extends ServiceImpl<ZjgkjEntryMapper, ZjgkjEntry>
        implements ZjgkjEntryService {

    @Resource
    private ZjgkjEntryMapper zjgkjEntryMapper;

    @Override
    public List<ZjgkjEntry> getAll(GetAllReq req) {
        return zjgkjEntryMapper.getAll(req);
    }

    @Override
    public AjaxResult addEntry(ZjgkjEntry zjgkjEntry) {
        //重复校验
//        if(zjgkjEntryMapper.selectByNameOrProjectName(zjgkjEntry) != null){
//            return AjaxResult.error("姓名或项目名称已存在，请勿重复提交。");
//        }
        zjgkjEntry.setStatus(0);

        if (zjgkjEntryMapper.add(zjgkjEntry)) {
            return AjaxResult.success("提交成功！");
        }
        return AjaxResult.error();
    }

    @Override
    public AjaxResult updateEntry(ZjgkjEntry zjgkjEntry) {
        return zjgkjEntryMapper.update(zjgkjEntry)?AjaxResult.success("修改成功！"):AjaxResult.error("修改失败！");
    }

    @Override
    public AjaxResult deleteEntry(Long id) {
        ZjgkjEntry entry = zjgkjEntryMapper.getById(id);
        if(entry == null){
            return AjaxResult.error("未找到数据");
        }
        entry.setIsDelete(1);
        return zjgkjEntryMapper.update(entry)?AjaxResult.success("删除成功！"):AjaxResult.error("删除失败！");
    }
}




